double diffLength(const CGPoint *a, const CGPoint *b);
double gettimeofday_sec();

#import <UIKit/UIView.h>
#import <GraphicsServices/GraphicsServices.h>

@class NSTimer;

enum
{
	SAME_POINT_MARGIN = 32,
	CLICK_INTERVAL = 100,	// ms, 名前が合っていない
	CLICK_TIMEOUT = 200,	// ms, 名前が合っていない
};

@interface MousePanel: UIView
{
	// delegate
	id mouseDelegate;
	
	// single finger
	CGPoint prevPoint;
	CGPoint mouseDownPoint;
	double mouseDownTime, mouseUpTime;
	
	BOOL mouseMoved;
	
	// drag
	BOOL leftDragging, rightDragging;
	
	// gesture
	CGPoint gesStart1, gesStart2, gesEnd1, gesEnd2;
	CGPoint prevP1, prevP2;
	double gesStartTime;
	
	// click timer
	NSTimer *leftClickTimer, *rightClickTimer;
}

- (id)initWithFrame: (CGRect)frame;
- (void)dealloc;

- (void)setMouseDelegate: (id)delegate;

- (BOOL)canHandleGestures;

- (void)gestureStarted: (GSEventRef)event;
- (void)gestureEnded: (GSEventRef)event;
- (void)gestureChanged: (GSEventRef)event;

- (void)mouseDragged: (GSEventRef)event;
- (void)mouseDown: (GSEventRef)event;
- (void)mouseUp: (GSEventRef)event;

- (void)sendMouseLeftButtonClick: (NSTimer *)timer;
- (void)sendMouseRightButtonClick: (NSTimer *)timer;

@end
